package com.xigua.JucOfBeautiful.chapterSix._6_2;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2022/2/1321:02
 */
public class ConditionTest {
    private  static ReentrantLock lock = new ReentrantLock();


    public static void main(String[] args) {
        Condition condition = lock.newCondition();
        lock.lock();
        try {
            System.out.println("begin wait");
            condition.await();
            System.out.println("end wait");
        }catch (Exception e){

        }finally {
            lock.unlock();
        }
        lock.lock();
        try {
            System.out.println("begin signal");
            condition.signal();
            System.out.println("end signal");
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            lock.unlock();
        }


    }


}
